package com.sakura.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sakura.po.Actor;
import com.sakura.service.BeCommentService;
import com.sakura.dao.BeCommentMapper;
import com.sakura.po.BeComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("BeCommentService")
public class BeCommentServiceImpl implements BeCommentService {

    @Autowired
    private BeCommentMapper beCommentMapper;

    @Override
    public void addBecomment(BeComment beComment){
        beCommentMapper.insertBeComment(beComment);
    }

    @Override
    public BeComment getBecomment(Integer id){
        return beCommentMapper.getBecomment(id);
    }

    @Override
    public void updateBecomment(BeComment beComment){
        beCommentMapper.updateBeComment(beComment);
    }

    @Override
    public void deleteBecomment(List<String> ids){
        for(String id:ids){
            beCommentMapper.deleteBeComment(Integer.valueOf(id));
        }
    }


    @Override
    public PageInfo<BeComment> getAllBeComments(BeComment beComment, int page, int limit){
        PageHelper.startPage(page,limit);
        List<BeComment> list=beCommentMapper.getAllBeComments(beComment);
        PageInfo<BeComment> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }


}
